<!DOCTYPE html>
<html>
<head>
    <title>商店信息</title>
    <#include "/header.html">
    <style>
        .layui-form-label {
            width: 110px;
        }
        .layui-rate {
            padding: 0;
        }
        .layui-rate .layui-inline {
            margin: inherit;
        }
        .layui-rate li i.layui-icon {
            font-size: 15px;
        }
        .store-album {
            cursor: pointer;
        }
    </style>
</head>
<body class="bg-white">

<div id="appMain">
</div>

<script type="text/html" id="storeInfoTpl">
    <div class="layui-fluid">
        <form class="layui-form layuimini-form" action="" lay-filter="dataForm">
            <div class="layui-row">
                <div class="layui-col-md10">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">用户名称：</label>
                                <div class="layui-form-mid">{{d.info.userName}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">手机号：</label>
                                <div class="layui-form-mid">{{d.info.userMobile}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">店铺名称：</label>
                                <div class="layui-form-mid">{{d.info.name}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">地址：</label>
                                <div class="layui-form-mid">{{d.info.address}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">销售额：</label>
                                <div class="layui-form-mid">{{d.info.salesAmount}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">总评分：</label>
                                <div class="layui-form-mid">
                                    <div id="ratingView"></div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">入驻时间：</label>
                                <div class="layui-form-mid">{{d.info.createTime}}</div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label layui-word-aux">最后更新时间：</label>
                                <div class="layui-form-mid">{{d.info.updateTime}}</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md2">
                    <div>
                        {{# if(d.info.avatar != ''){ }}
                        <img src="{{d.info.avatar}}" width="70" alt="">
                        {{# } else { }}
                        <img src="${request.contextPath}/statics/images/avatar.png" width="70" alt="">
                        {{# } }}
                    </div>
                    <div style="padding: 10px 0 0;">
                        {{# if(d.info.status == 90){ }}
                        <span class="layui-badge badge-lg layui-bg-black">已关闭</span>
                        {{# } else if(d.info.status == 40){ }}
                        <span class="layui-badge badge-lg layui-bg-black">已禁用</span>
                        {{# } else if(d.info.status == 20){ }}
                        <span class="layui-badge badge-lg layui-bg-red">已驳回</span>
                        {{# } else if(d.info.status == 10){ }}
                        <span class="layui-badge badge-lg layui-bg-green">已认证</span>
                        {{# } else { }}
                        <span class="layui-badge badge-lg layui-bg-grey">待审核</span>
                        {{# } }}
                    </div>
                </div>
                <div class="layui-col-md10">
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-word-aux">店铺相册：</label>
                        <div class="layui-form-mid" id="layer-photos-view">
                            {{# layui.each(d.info.images, function(i, src){ }}
                            <img class="store-album" layer-pid="{{i}}" layer-src="{{src}}" src="{{src}}" width="60" alt="">
                            {{# }); }}
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">&nbsp;</div>
            <fieldset class="layui-elem-field layui-field-title">
                <legend>实名信息</legend>
            </fieldset>
            <div class="layui-row">
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-word-aux">真实姓名：</label>
                        <div class="layui-form-mid">{{d.auth.name}}</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-word-aux">身份证号：</label>
                        <div class="layui-form-mid">{{d.auth.idCard}}</div>
                    </div>
                </div>
                <div class="layui-col-md8">
                    <div class="layui-row">
                        <div class="layui-col-md3">
                            <div class="layui-word-aux">身份证正面</div>
                            <div><img src="{{d.auth.cardFront}}" alt="" width="80"></div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-word-aux">身份证背面</div>
                            <div><img src="{{d.auth.cardBack}}" alt="" width="80"></div>
                        </div>
                        <div class="layui-col-md3">
                            <div class="layui-word-aux">手持身份证</div>
                            <div><img src="{{d.auth.cardHands}}" alt="" width="80"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <div class="layui-input-block">
                    <button class="layui-btn" id="btnPass" lay-submit lay-filter="btnPass">通过认证</button>
                    <button class="layui-btn" id="btnRefuse" lay-submit lay-filter="btnRefuse">拒绝认证</button>
                    <button class="layui-btn" id="btnClose" lay-submit lay-filter="btnClose">关闭店铺</button>
                    <button class="layui-btn" id="btnActive" lay-submit lay-filter="btnActive">激活店铺</button>
                    <button class="layui-btn" id="btnCloseWin" lay-submit lay-filter="btnCloseWin">关闭窗口</button>
                </div>
            </div>
        </form>
    </div>
</script>

<script type="text/html" id="buttonsTpl">
    {{# if(d.status == 0){ }}
    <button class="layui-btn" ref="#btnPass">通过认证</button>
    <button class="layui-btn layui-btn-warm" ref="#btnRefuse">拒绝认证</button>
    {{# } }}
    {{# if(d.status == 10){ }}
    <button class="layui-btn layui-btn-danger" ref="#btnClose">关闭店铺</button>
    {{# } }}
    {{# if(d.status == 40){ }}
    <button class="layui-btn layui-btn-normal" ref="#btnActive">激活店铺</button>
    {{# } }}
    <button class="layui-btn layui-btn-primary" ref="#btnCloseWin">关闭窗口</button>
</script>

<script type="text/javascript">
    layui.use(['form', 'laytpl', 'rate'], function () {
        var form = layui.form,
            rate = layui.rate,
            laytpl = layui.laytpl,
            $ = layui.$;

        $(".layui-layer-btn0", parent.document).hide();
        $(".layui-layer-btn.layui-layer-btn-c button.layui-btn", parent.document).remove();

        var _parent = parent;
        if(_parent.formDataId > 0) {
            $.ajax({
                type: "POST",
                url: serverUrl('app/store/info/' + _parent.formDataId),
                success: function (result) {
                    if (result.code === 0) {
                        laytpl($("#storeInfoTpl").html()).render(result, function(html){
                            $("#appMain").html(html);
                        });
                        laytpl($("#buttonsTpl").html()).render(result.info, function(html){
                            $(".layui-layer-btn.layui-layer-btn-c", parent.document).prepend(html);
                            _parent.btnEvent();
                        });
                        rate.render({
                            elem: '#ratingView'
                            , length: 5
                            , value: result.info.rating
                            , half: true
                            , text: false
                            , readonly: true
                        });
                        layer.photos({
                            photos: '#layer-photos-view'
                            ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                        });
                    }
                }
            });
        }


        var changeStatus = function(title, status) {
            layer.confirm(title, {icon: 3, title:'提示'}, function(index){
                var params = {
                    id: _parent.formDataId,
                    status: status
                };
                submitFormData('app/store/update', params);
            });
        }

        form.on('submit(btnPass)', function (data) {
            changeStatus('确定通过认证吗？', 10);
            return false;
        });
        form.on('submit(btnRefuse)', function (data) {
            changeStatus('确定拒绝认证吗？', 20);
            return false;
        });
        form.on('submit(btnClose)', function (data) {
            changeStatus('确定关闭店铺吗？', 40);
            return false;
        });
        form.on('submit(btnActive)', function (data) {
            changeStatus('确定激活店铺吗？', 10);
            return false;
        });
        form.on('submit(btnCloseWin)', function (data) {
            var iframeIndex = _parent.layer.getFrameIndex(window.name);
            _parent.layer.close(iframeIndex);
        });

    });
</script>
</body>
</html>